<%-- 
    Document   : index
    Created on : 20 Sep 11, 10:04:26
    Author     : INSPIRON_1427
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.beans.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<form id="form1" name="form1" method="post" action="">
  Masukkan nama anda
    <input type=text name=textfield >
    
    <form id="form2" name="form2" method="post" action="">
  <p>
    <input name="RB" type="radio" value="Pria" checked="checked" />
  Pria
  <input name="RB" type="radio" value="Wanita" />
  Wanita</p>
  <P><input type="submit" name="Submit" value="Submit" />
</form>
</form>


<%
String  tes = request.getParameter ("textfield");
String tes2 = request.getParameter ("RB");
if(request.getParameter("BR") != null) {
                if(request.getParameter("RB").equals("Pria")) {
                    out.println("Anda adalah pria sejati");
                }
                else {
                    out.println("Anda bukan perempuan");
                }
                }


Connection connection = null;
    Class.forName("com.mysql.jdbc.Driver");

    String url = "jdbc:mysql://localhost/testdb";
    String user = "root";
    String password = "";
    connection = DriverManager.getConnection(url, user, password);

    Statement stmt = connection.createStatement();
    String sql = "INSERT INTO users (tes, tes2) VALUES ('', '')";
    stmt.execute(sql);
    connection.close();
%>


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Nama Anda = <%=tes%></h1>
        <h1>Jenis kelamin = <%=tes2%></h1>
    </body>
</html>